//
//  MedicineRemindVC.swift
//  SDKDebuggingDemo
//
//  Created by 秦晟哲 on 2020/7/11.
//  Copyright © 2020 QinszQSZ. All rights reserved.
//

import UIKit

class MedicineRemindVC: UIViewController,BLESetMedicineRemindDelegate {

    @IBOutlet weak var outputTextView: UITextView!
    
    
    var setTask:KCTBLESetMedicineRemindTask?
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    @IBAction func clickBackButton(_ sender: Any) {
        self.navigationController?.popViewController(animated: true)
    }
    
    @IBAction func clickSetButton(_ sender: Any) {
        
        outputTextView.text = nil
        
        SVProgressHUD.show()
        
        let model_0 = KCTBLEMedicineRemindModel.init()
        model_0.hour = 8
        model_0.minute = 10
        model_0.weekRepeat = (0x01 | 0x01<<1)// 周一、周二
        model_0.content = "药品_0"
        
        let model_1 = KCTBLEMedicineRemindModel.init()
        model_1.hour = 8
        model_1.minute = 10
        model_1.weekRepeat = (0x01<<2 | 0x01<<3)// 周三、周四
        model_1.content = "药品_1"
        
        setTask = KCTBLESetMedicineRemindTask.init(flashVersion: arc4random(), reminds: [model_0,model_1])
        setTask?.delegate = self
        setTask?.resume()
    }
    
    
    func BLESetMedicineRemindProgress(task: KCTBLESetMedicineRemindTask, successCount: Int, totalCount: Int) {
        outputTextView.text = "进度:\(successCount)/\(totalCount)"
    }
    
    func BLESetMedicineRemindCompletion(task: KCTBLESetMedicineRemindTask, success: Bool, failureType: MedicineRemindFailureType, failureDes: String?) {
        SVProgressHUD.dismiss()
        outputTextView.text = "success:\(success),failureType:\(failureType.rawValue),failureReason:\(failureDes ?? "nil")"
    }
    
    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
